package R

import (
	"encoding/json"
	"fmt"
	"net/http"
	"server/lib/Imartini"
	// "time"
)

func Write(res http.ResponseWriter, g Imartini.G, ret map[string]interface{}) error {
	b, err := json.Marshal(ret)
	if err != nil {
		return err
	}
	res.Header().Add("Access-Control-Allow-Origin", "*")
	res.Header().Set("Content-Type", "application/json; charset=UTF-8")
	res.Write(b)
	Imartini.AddLog(g, fmt.Sprintf("\napi:%s", b))
	return nil
}
